All Questions
Tagged with text-processingawk
2,977 questions
1vote
3answers
66views
edit all the values in a specific column based on row numbers range
I have a PDB file (coordinates of atoms in a protein) on a Linux machine: ATOM 1 N GLY A 1 0.535 51.766 5.682 1.00 0.00 ATOM 2 CA GLY A 1 -0.712 50....
4votes
5answers
473views
Remove the first field (and leading spaces) with a single AWK
Consider this input and output: foo bar baz bar baz How do you achieve with a single AWK? Please explain your approach too. These are a couple tries: $ awk '{ $1 = ""; print(substr($0, 2)) ...
1vote
2answers
87views
Filter for arbitrary AND patterns [duplicate]
Consider a command which takes arguments like this: cmd foo bar baz [arbitrary args...]. How do you build a filter of AND patterns based on those arguments? Something like this pipeline of greps: grep ...
4votes
3answers
220views
Add columns from variable number of files to base file
I'm dealing with a series of bed files, which look like this: chr1 100 110 0.5 chr1 150 175 0.2 chr1 200 300 1.5 With the columns being chromosome, start, end, score. I have multiple different files ...
0votes
2answers
90views
BSD sed/awk moving portion of line to line above (switching attribute in HTML file)
My situation is simple : I have an HTML file with several lines containing only the indented <section> block tag, each line followed by an (also indented) <h3 id="YYYY">...</...
2votes
3answers
86views
Printing a specific section everytime search results are matched
I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References. This is what it looks like Chapter: 1 One: Birds and Trees Birds are beautiful and trees ...
3votes
3answers
411views
duplicate columns with AWK and separate them by tab
I have a large file with the following format tab-separated: #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT recombination chr1 586001 >63041388>63041391 G ...
0votes
4answers
165views
Aligning space separated words in columns
There is a text file, file.txt. In there is: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... How to format this to an output like this: abc 01245 def-1 32154 ghi-3 55432 jkl ...
1vote
1answer
90views
awk won't use literal '\\n' as a delimiter
I have the following file of text that I need to use to give to a Discord webhook: some\nText\nHere The \n separators are literal characters, not actual new lines (the webhook parses them later as new ...
-2votes
3answers
113views
Awk to pick up json values
I am trying to get the job status from the below json file.. but while using awk it is returning { "id": 10870, "type": "job", "url": "/api/v2/...
2votes
7answers
275views
merge multiple files using full join by the first column
I have a directory with 200 samples. Each file has two columns. I want to full join these files and make a joined file This is the example of $ head 346_T1_A_deduped.bismark.cov_format 1_10525 95.2 ...
3votes
3answers
355views
Large file manipulation
I have a Garmin Nuvi which uses OpenStreet maps. Garmin do postcodes, but is usually 2-3 years out of date for Scotland. OSM does not do British postcodes, but the Post office does, and it can be ...
3votes
6answers
393views
Print lines between two patterns where first pattern appears more than once before second pattern
I am trying to find a way to use awk to print the lines between two patterns, Virtual and Redirect, but only if the two patterns are consecutive, exclusive of any other strings between them. Example ...
1vote
3answers
112views
sed: To match a newline and spaces
I have a following file: <head> <title>this is a title</title> <style> here goes a style sheet </style> </head> I need to strip the <title> element ...
7votes
6answers
753views
Split column into lines using awk
I have a file that contains a long column and I want to split it into lines, each one with 5 values. E.g., Input file: 1 2 3 4 5 6 7 8 9 10 Output file: 1 2 3 4 5 6 7 8 9 10